﻿using System;
using System.Collections.Generic;
using System.Text;
using Castle.ActiveRecord;
using Castle.Components.Validator;
using MiragePWF.NH.Validation;
using Wolfut.MirageEE.Kernal.Common;
using Wolfut.MirageEE.Domain.CommonUtilities;

namespace Wolfut.MirageEE.Domain.Products
{
    [ActiveRecord("PRODUCTS")]
    public class Product:PersistentObjectWithGuid
    {
        #region 商品编号
        private string productNo = string.Empty;
        /// <summary>
        /// 商品编号
        /// </summary>
        [Property("PRODUCT_CODE")]
        [ValidateIsUniqueInSameTransactionWithString(false, "数据库已经存在相同的商品编号！")]
        [ValidateNonEmpty, ValidateLength(0, 100, "商品编号超长！")]
        public virtual string ProductCode
        {
            get
            {
                return productNo;
            }
            set
            {
                productNo = value;
            }
        }
        #endregion

        #region 商品名称
        private string productName = string.Empty;

        /// <summary>
        /// 商品名称
        /// </summary>
        [Property("PRODUCT_NAME")]      
        [ValidateNonEmpty, ValidateLength(0, 200, "商品名称超长！")]
        public virtual string ProductName
        {
            get
            {
                return productName;
            }
            set
            {
                productName = value;
            }
        }
        #endregion

        #region 产品规格
        private string productSpec = string.Empty;
        [Property("PRODUCT_SPEC")]      
        [ValidateLength(0, 50, "产品规格超长！")]
        public virtual string ProductSpec
        {
            get
            {
                return productSpec;
            }
            set
            {
                productSpec = value;
            }
        }
        #endregion

        #region 商品类别
        private string productCategory = string.Empty;
        [Property("PRODUCT_CATEGORY")]
        [ValidateLength(0, 100, "商品类别超长！")]
        public virtual string ProductCategory
        {
            get
            {
                return productCategory;
            }
            set
            {
                productCategory = value;
            }
        }
        #endregion

        #region 计量单位
        private string unit = string.Empty;
        /// <summary>
        /// 计量单位
        /// </summary>
        [Property("MEASURE_UNIT")]
        [ValidateLength(0, 10, "计量单位超长！")]
        public virtual string Unit
        {
            get
            {
                return unit;
            }
            set
            {
                unit = value;
            }
        }
        #endregion

        #region 条形码
        private string barCode = string.Empty;
        [Property("BARCODE")]
        [ValidateLength(0, 100, "条形码超长！")]
        public virtual string BarCode
        {
            get
            {
                return barCode;
            }
            set
            {
                barCode = value;
            }
        }
        #endregion

        #region 商品图片
        private string imageUrl = string.Empty;
        /// <summary>
        /// 商品图片
        /// </summary>
        [Property("IMAGE_URL")]
        [ValidateLength(0, 255, "商品图片超长！")]
        public virtual string ImageUrl
        {
            get
            {
                return imageUrl;
            }
            set
            {
                imageUrl = value;
            }
        }
        #endregion

        #region 商品图片内容
        private byte[] pictureContent;
        [Property("PICTURE_CONTENT")]
        public virtual byte[] PictureContent
        {
            get
            {
                return pictureContent;
            }
            set
            {
                pictureContent = value;
            }
        }
        #endregion

        #region 标准售价
        private Decimal stdSellPrice;
        [Property("STANDARD_SALE_PRICE")]
        public virtual Decimal StdSellPrice
        {
            get
            {
                return stdSellPrice;
            }
            set
            {
                stdSellPrice = value;
            }
        }
        #endregion

        #region 标准买价
        private Decimal stdBuyPrice;
        [Property("STANDARD_BUY_PRICE")]
        public virtual Decimal StdBuyPrice
        {
            get
            {
                return stdBuyPrice;
            }
            set
            {
                stdBuyPrice = value;
            }
        }
        #endregion

        #region 最高采购价
        private Decimal maxBuyPrice;
        [Property("MAX_BUY_PRICE_FIXING")]
        public virtual Decimal MaxBuyPrice
        {
            get
            {
                return maxBuyPrice;
            }
            set
            {
                maxBuyPrice = value;
            }
        }
        #endregion

        #region 最低售价
        private Decimal minSellPrice;
        [Property("MIN_SELL_PRICE_FIXING")]
        public virtual Decimal MinSellPrice
        {
            get
            {
                return minSellPrice;
            }
            set
            {
                minSellPrice = value;
            }
        }
        #endregion

        #region 最低存货量
        private Decimal minInStockAmount;
        [Property("MIN_STOCK_SUM")]
        public virtual Decimal MinInStockAmount
        {
            get
            {
                return minInStockAmount;
            }
            set
            {
                minInStockAmount = value;
            }
        }
        #endregion

        #region 增值税税率
        private Decimal taxRate;
        [Property("VALUE_ADDED_TAX_RATE")]       
        public virtual Decimal TaxRate
        {
            get
            {
                return taxRate;
            }
            set
            {
                taxRate = value;
            }
        }
        #endregion

        #region 下架/上架
        [Property("IS_SELLING")]       
        public virtual ProductSellingState IsSelling
        {
            get
            {
                return isSelling;
            }
            set
            {
                isSelling = value;
            }
        }
        private ProductSellingState isSelling = ProductSellingState.WaitingForSale;
        #endregion

        #region 所属网店分类
        /// <summary>
        /// 01：淘宝；02：拍拍；03：易趣；04：其它；
        /// </summary>
        [Property("ESHOP_CATEGORY")]
        [ValidateLength(0, 100, "所属网店分类超长！")]
        public virtual ShopCategory EShopCategory
        {
            get
            {
                return eShopCategory;
            }
            set
            {
                eShopCategory = value;
            }
        }
        private ShopCategory eShopCategory = ShopCategory.TaoBao;
        #endregion

        #region 存货描述
        /// <summary>
        /// 存货描述
        /// </summary>
        String productDesc = string.Empty;
        [Property("PRODUCT_DESC")]
        [ValidateLength(0, 2000, "存货描述超长！")]
        public virtual string ProductDesc
        {
            get
            {
                return productDesc;
            }
            set
            {
                productDesc = value;
            }
        }
        #endregion

        #region 逻辑删除
        private Boolean isDeleted;
        [Property("IS_DELETED")]
        public virtual Boolean IsDeleted
        {
            get
            {
                return isDeleted;
            }
            set
            {
                isDeleted = value;
            }
        }
        #endregion

        #region 默认存货地点（仓库ID）
        private string productWarebasesID;
        /// <summary>
        /// 默认存货地点
        /// </summary>
        [Property("WAREHOUSES_ID")]
        [ValidateLength(0, 40, "默认存货地点超长！")]
        public virtual string DefaultWareHouse
        {
            get
            {
                return productWarebasesID;
            }
            set
            {
                productWarebasesID = value;
            }
        }
        #endregion
    }
}
